package com.pac.role.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.pac.role.bean.RoleBean;
import com.pac.role.dao.RoleDao;

/**
 * 角色Dao实现
 * 
 * @author lujun.chen
 * @version [版本号, 2015年2月14日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Repository(value = "roleDao")
public class RoleDaoImpl implements RoleDao {

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public String addRole(RoleBean roleBean) {
		sqlSessionTemplate.insert("addRole", roleBean);
		return roleBean.getId();
	}

	@Override
	public boolean updateRole(RoleBean roleBean) {
		int n = sqlSessionTemplate.update("updateRole", roleBean);
		return n > 0;
	}

	@Override
	public boolean delRole(RoleBean roleBean) {
		int n = sqlSessionTemplate.delete("delRole", roleBean);
		return n > 0;
	}

	@Override
	public List<RoleBean> queryRole(RoleBean roleBean) {
		return sqlSessionTemplate.selectList("queryRole", roleBean);
	}

}
